package org.tank.sigleton;

public class LazyMode {


    private  static  volatile LazyMode lazyMode;




    private LazyMode(){

    }

    public static LazyMode getLazyMode(){
        if(lazyMode==null){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (Object.class){
             if(lazyMode==null) {
                 lazyMode=new LazyMode();
             }
            }
        }
        return lazyMode;
    }

    public static void main(String[] args) {
        for (int i = 0; i <100 ; i++) {

            new Thread(()->{
                LazyMode lazyMode1 = LazyMode.getLazyMode();
                System.out.println(lazyMode1.hashCode());

            }



            ).start();
        }
    }
}
